package xddq

import (
	"fmt"
	"time"
	D "websocket_apn/define"
	"websocket_apn/log"
	"websocket_apn/proto"
)

//解析轮回秘境-千界战场的结果
func (xd *XdDriver) CheckLunHuiMiJingInfoData(allInfo []D.LunHuiMiJingInfo) {
	leftTime := xd.UserData.Activity[D.Activity_Reincarnation_Secret_Realm].EndTime.Sub(time.Now())
	if leftTime < 10*time.Hour {
		xd.Send(proto.Get_Cmd_Data(xd.userInfo.PlayerId, proto.S_REBORN_TRIAL_USE_ITEM_REQ, fmt.Sprintf("08 %s 10 C0 8E 06 18 05", xd.UserData.Activity[D.Activity_Reincarnation_Secret_Realm].ID)))
	}
	for _, info := range allInfo {
		if info.YmID == xd.UserData.YaoMengID {
			continue
		}
		for i := 0; i < 5; i++ {
			log.Infof("轮回秘境-千界战场，开始攻击排名%d的%s", info.Ranking, info.Name)
			xd.Send(proto.Get_Cmd_Data(xd.userInfo.PlayerId, proto.S_REBORN_TRIAL_BATTLE_CHALLENGE_REQ, fmt.Sprintf("08 %s 10 %s", xd.UserData.Activity[D.Activity_Reincarnation_Secret_Realm].ID, info.YmID)))
			time.Sleep(1 * time.Second)
		}
		break
	}
}
